#include <bits/stdc++.h>
// 2025/02/04
// tag: 
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

int n, h[101], dp1[101], dp2[101];

bool check(){
    int i;
    for (i = 1; i <= n; i++)
        if (h[i] <= h[i - 1])
            break;
    for (; i <= n; i++)
        if (h[i] >= h[i - 1])
            break;
    if (i <= n)
        return false;
    return true;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    if (check()){
        cout << 0 << endl;
        return 0;
    }
    dp1[1] = 1;
    for (int i = 2; i <= n; i++) {
        dp1[i] = 1;
        for (int j = 1; j < i; j++)
            if (h[j] < h[i]) 
                dp1[i] = max(dp1[i], dp1[j] + 1);
    }
    dp2[n] = 1;
    for (int i = n - 1; i >= 1; i--) {
        dp2[i] = 1;
        for (int j = n; j > i; j--)
            if (h[j] < h[i])
                dp2[i] = max(dp2[i], dp2[j] + 1);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            if (h[i] > h[j])
                ans = max(ans, dp1[i] + dp2[j]);
    cout << n - ans << endl;
    return 0;
}